﻿using System;
using CookComputing.XmlRpc;


namespace sklik_api
{


    public struct LoginIn
    {
        public int status; // status (200=OK)
        public string statusMessage; // slovní popis statusu        
        public string session; // slovní popis statusu            
    }

    public struct LoginOut
    {
        public int status; // status (200=OK)
        public string statusMessage; // slovní popis statusu        

    }


    public struct ClientAttributOut
    {
        public int status; // status (200=OK)
        public string statusMessage; // Status code description         
        public string session; // Refreshed session 
        public DateTime sessionStarted;
        public User user;
        public foreignAccountsLstItem[] foreignAccounts; //

        public struct User
        {
            public int userId;//	 User Id
            public string username;//	 Username
            public string agencyStatus;
            public int walletCredit;
            public int walletCreditWithVat;
            public bool walletVerified;
            [XmlRpcMissingMapping(MappingAction.Ignore)]
            public int dayBudgetSum;
            [XmlRpcMissingMapping(MappingAction.Ignore)]
            public int accountLimit;
        }
    }

    public struct foreignAccountsLstItem
    {
        public int userId;	 //userId Foreign account user id
        public string username;	// Foreign account username
        public string access;	// Access type / r: Read-only rw: / Read-write
        public string relationName;
        public string relationStatus;
        public string relationType;
        public int walletCredit;
        public int walletCreditWithVat;
        public bool walletVerified;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int accountLimit;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public object dayBudgetSum;

        public foreignAccountsLstItem(XmlRpcStruct s)
        {
            userId = Convert.ToInt32(s["userId"]);
            username = s["username"].ToString();
            access = s["removed"].ToString();
            relationName = s["relationName"].ToString();
            relationStatus = s["relationStatus"].ToString();
            relationType = s["relationType"].ToString();
            walletCredit = Convert.ToInt32(s["walletCredit"]);
            walletCreditWithVat = Convert.ToInt32(s["walletCreditWithVat"]);
            walletVerified = Convert.ToBoolean(s["walletVerified"]);
            accountLimit = Convert.ToInt32(s["accountLimit"]);
            dayBudgetSum = Convert.ToInt32(s["dayBudgetSum"]);
        }
    }


    public struct listCampaigns
    {

        public int status; // status (200=OK)
        public string statusMessage; // Status code description         
        public string session; // Refreshed session 
        public CampaingListItem[] campaigns; //  
    }



    public struct CampaingListItem
    {
        public int id; 	 // Campaign id
        public string name; // Campaign name
        public bool removed;	// Whether campaign is deleted
        public string status; //Campaign status active: Active / suspend: Suspended
        public int dayBudget; // 	Campaign day budget (in halers)
        public int exhaustedDayBudget; 	// How much of the day budget is already exhausted (in halers)
        public string adSelection; // 	Ad selection type weighted: Weighted ad selection random: Random ad selection
        public DateTime createDate; //	Campaign create date
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int totalBudget; //
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int exhaustedTotalBudget; //
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int totalClicks; //
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int exhaustedTotalClicks; //
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int premisedId; //

        public CampaingListItem(XmlRpcStruct s)
        {
            id = (int)s["id"];
            name = s["name"].ToString();
            removed = Convert.ToBoolean(s["removed"]);
            status = s["status"].ToString();
            dayBudget = (int)s["dayBudget"];
            exhaustedDayBudget = (int)s["exhaustedDayBudget"];
            adSelection = s["adSelection"].ToString();
            createDate = Convert.ToDateTime(s["createDate"]);
            totalBudget = Convert.ToInt32(s["totalBudget"]);
            exhaustedTotalBudget = Convert.ToInt32(s["exhaustedTotalBudget"]);
            totalClicks = Convert.ToInt32(s["totalClicks"]);
            exhaustedTotalClicks = Convert.ToInt32(s["exhaustedTotalClicks"]);
            premisedId = Convert.ToInt32(s["premisedId"]);
        }

    }


    public struct CampaingStat
    {
        public int status; // status (200=OK)
        public string statusMessage; // Status code description         
        public string session; // Refreshed session 
        public CampaingStatsStats stats;
        public CampaingStatsFulltext fulltext;
        public CampaingStatsContext context;
    }


    public struct CampaingStatsStats
    {
        public double avgPosition;
        public int clicks;
        public int impressions;
        public int conversions;
        public int transactions;
        public int value;
        public int money;

    }

    public struct CampaingStatsFulltext
    {
        public double avgPosition;
        public int clicks;
        public int impressions;
        public int conversions;
        public int transactions;
        public int value;
        public int money;

    }

    public struct CampaingStatsContext
    {
        public double avgPosition;
        public int clicks;
        public int impressions;
        public int conversions;
        public int transactions;
        public int value;
        public int money;
    }


    public struct ReportAttributes
    {

        public int status; // status (200=OK)
        public string statusMessage; // Status code description         
        public string session; // Refreshed session 

        public Report report; //  
    }


    public struct Report
    {
        public int id;
        public string name;
        public string status;
        public DateTime startDate;//	 Report start date
        public DateTime endDate;//	 Report end date
        public DateTime requestDate;//	 When the report was requested
        public DateTime generatedDate;//	 When the reported was finished (or nil if it is not finished)
        public string granularity;//	 Report granularity total
        public bool context;//	 Whether statitics for context are included
        public bool fulltext;//	 Whether statitics for fulltext are included
        public string reportType;//	 For what items are statistics computed
        public string itemsIncluded;//	 What items are included
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public CampaignIds[] campaignIds;
        public ReportData data;
    }


    public struct CampaignIds
    {
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int id;//Item id (campaign id if reportType is campaign etc.)

        public CampaignIds(XmlRpcStruct s)
        {
            id = (int)s["id"];
        }
    }




    public struct ReportData
    {
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public Reportsummary summary;
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public string[] header;
        // [XmlRpcMissingMapping(MappingAction.Ignore)]
        public object[][] rows;
    }

    public struct Reportsummary
    {
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int impressions;//	(optional) Impression count
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int clicks;//	(optional) Click count
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int money;//	(optional) Click count
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int conversions;//	(optional) Conversion count
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int transactions;//	(optional) Transaction count
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double avgPosition;//	(optional) Average ad position
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double ctr;//	(optional) CTR (or nil if no impressions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double avgCpc;//	(optional) Average CPC (or nil if no clicks; in halers)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double conversionRate;//	(optional) Conversion count / click click count (or nil if no clicks; value 1 means 100 %)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double conversionAvgCost;//	(optional) Average cost of one conversion (or nil if conversions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double conversionAvgValue;//	(optional) Average value of one conversion (or nil if no conversions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double conversionValueCostRatio;//	(optional) Conversion value / cost (or nil if no clicks)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double transactionAvgCost;//	(optional) Average cost of one transaction (or nil if no transactions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double transactionAvgValue;//	(optional) Average value of one transaction (or nil if no transactions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public double avgTransactions;//	(optional) Average count of transactions per one conversion (or nil if no conversions)
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int firmy_mapShow;//	(optional) How many times was the map (from association with firmy.cz) shown
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int firmy_mapClick;//	(optional) How many times was the map clicked
        [XmlRpcMissingMapping(MappingAction.Ignore)]
        public int firmy_firmyClick;//	(optional) Firmy.cz association detail click count
    }


    //ListReports
    public struct listReports
    {

        public int status; // status (200=OK)
        public string statusMessage; // Status code description         
        public Reports[] reports; //  
        public string session; // Refreshed session 
    }

    public struct Reports
    {
        public int id;
        public string name;
        public string status;
        public DateTime startDate;
        public DateTime endDate;
        public DateTime requestDate;
        public DateTime generatedDate;

        public Reports(XmlRpcStruct s)
        {
            id = (int)s["id"];
            name = s["name"].ToString();
            status = s["status"].ToString();
            startDate = Convert.ToDateTime(s["startDate"]);
            endDate = Convert.ToDateTime(s["endDate"]);
            requestDate = Convert.ToDateTime(s["requestDate"]);
            generatedDate = Convert.ToDateTime(s["generatedDate"]);
        }
    }
}

